package com.tarena.csmall.seckill.controller;

import cn.tedu.mall.common.restful.JsonPage;
import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.pojo.seckill.vo.SeckillSpuVO;
import com.tarena.csmall.seckill.service.SeckillSpuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SeckillSpuController {
    @Autowired
    private SeckillSpuService seckillSpuService;
    @GetMapping("/seckill/spu/list")
    public JsonResult<JsonPage<SeckillSpuVO>> listSpuSeckill(){
        JsonPage<SeckillSpuVO> pageSpu=seckillSpuService.listSpuSeckill();
        return JsonResult.ok(pageSpu);
    }
    /**
     * 根据spuId
     * 查询秒杀spu数据
     */
    @GetMapping("/seckill/spu/{spuId}")
    public JsonResult<SeckillSpuVO> getSeckillSpu(@PathVariable Long spuId){
        SeckillSpuVO seckillSpuVO=seckillSpuService.getSeckillSpu(spuId);
        return JsonResult.ok(seckillSpuVO);
    }
}
